
import http from "../utils/request"
// import axios,{CancelToken} from "./permissions"

export const getCaptcha = () => http.get("/users/getCaptcha?v=next")

//校验验证码
/**
 * 
 * @param {String} captcha 验证码 
 * @returns {Promise} 返回一个promise
 */
export const verifyCaptcha = captcha => http.get("/users/verifyCaptcha", {
    params: {
        captcha
    }
})

//获取手机验证码
export const getSmsCode = phoneNumber => http.post("/sms/send", { phoneNumber })


//手机验证码登录
export const smsLogin = code => http.post("/users/login?type=sms", { code })

//常规用户名登录
/**
 * 
 * @param {String} username 用户名
 * @param {String} password 用户密码
 * @returns {Promise} promise类型
 */
export const login = (username, password) => http.post("/users/login", { username, password })

//获取二维码
export const getQrcode = sid => http.get("/users/getQrcode", { params: { sid } })

//微信登录
export const wechatLogin = wechatCode => http.get("/users/wechatLogin", { params: { wechatCode } })

//获取日志
export const getLoginLogApi = (page = 1, count = 10) => http.get("/getloginlog", {

    params: {
        page, count
    }
})

//获取学员信息
/**
 * 
 * @param {Number} page 页码
 * @param {Number} count 每页显示的数量
 * @param {String} classes 班级
 * @returns {Promise} 返回一个promise的方法
 * 
 */
 export const getStulistApi = (page = 1, count = 10, classes = "") => http.get("/students/getstulist", {
    params: {
        page, count, class: classes
    }
})

//增加学员信息
export const addStuApi = data => http.post("/students/addstu", data)


///编辑学员信息 students/updatestu
export const updateStuApi = data => http.post("students/updatestu", data)

//删除学员信息   /students/delstu
export const delStuApi = sId => http.get("/students/delstu", { params: { sId } })

//获取班级列表    /students/getclasses
export const getClassesApi = () => http.get("/students/getclasses")

//搜索学员 /students/searchstu
export const searchStuApi = (page=1,key="",count=10) => http.get("/students/searchstu",{
    params:{
        page,
        key,
        count
        
    }
})